package com.yst.feign1.config;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class FilterConfig {

    @Autowired
    private PostFilter postFilter;

    @Bean
    public FilterRegistrationBean<PostFilter> registerPostFilter() {
        FilterRegistrationBean<PostFilter> registration = new FilterRegistrationBean<>();
        registration.setFilter(postFilter);
        registration.addUrlPatterns("/*");
        registration.setName("postFilter");
        registration.setOrder(1);  //值越小，Filter越靠前。
        return registration;
    }
}
